package com.zut.controller;

import cn.hutool.json.JSONUtil;
import com.zut.Pojo.Request.RunCodeEntity;
import com.zut.Pojo.UserRuncodeCase;
import com.zut.Service.ControllerServe.runCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequestMapping("/judge")
@RestController
public class JudgeController {

    @Autowired
    private runCode runCode;


   /**
   * @Author: 无恙
   * @Description: 运行测试样例接口
   */
    @PostMapping("/runCode")
    public List<UserRuncodeCase> RunCodeJudge(String message,String UserId){
        // 将message转换为CodeEntity对象
        RunCodeEntity codeEntity = JSONUtil.toBean(message,RunCodeEntity.class,true);

        List<UserRuncodeCase> caseResult = runCode.getCaseResult(codeEntity, UserId);


        return caseResult;

    }
}
